/**
 * 类的实现层次结构
 */
public class StringDisplayImpl extends DisplayImpl {

    private String string;
    private int width;

    public StringDisplayImpl(String string){
        this.string = string;
        this.width = string.length();
    }

    @Override
    public void openImpl() {
        println();
    }

    @Override
    public void printImpl() {
        System.out.println("| " + string + " |");
    }

    @Override
    public void closeImpl() {
        println();
    }

    private void println(){
        for(int i = 0; i < width; i++){
            System.out.print("-");
        }
        System.out.println();
    }
}
